<template>
	<el-main>
		<el-row :gutter="15">
			<el-col :lg="8">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option2"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option3"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option4"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option5"></scEcharts>
				</el-card>
			</el-col>
		</el-row>
	</el-main>
</template>

<script>
import scEcharts from '@/components/scEcharts';

/**
 * 引入组件 @/components/scEcharts
 * 组件内部会自动加载主题 @/components/scEcharts/echarts-theme-T.js
 * 支持props包括 height，width，option
 * 组件export百度Echarts所有方法，使用方式: new scEcharts[fun]
 */

export default {
	name: 'chart',
	components: {
		scEcharts
	},
	data() {
		return {
			option: {},
			option2: {
				title: {
					text: '工作量趋势',
					subtext: '按月份工作量趋势分析',
				},
				grid: {
					top: '80px'
				},
				tooltip: {
					trigger: 'axis'
				}
			},
			option3: {},
			option4: {},
			option5: {title: {
					text: '滞留工作排行',
				},},
		}
	},
	mounted() {
		this.getBiBpmFlowPie();
		this.getBiBpmFlowByDeptPie();
		this.getBiBpmFlowByMonthLine();
		this.getBiBpmFlowByAccountPie();
		this.getUserWorkForBar();
	},
	methods:{
		async getBiBpmFlowPie(){
			var res = await this.$API.bpm.echarts.getBiBpmFlowPie.get({model:'1'});
			if (res.code == 200) {
				this.option = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getBiBpmFlowByMonthLine(){
			var res = await this.$API.bpm.echarts.getBiBpmFlowByMonthLine.get({model:'1'});
			if (res.code == 200) {
				this.option2 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getBiBpmFlowByDeptPie(){
			var res = await this.$API.bpm.echarts.getBiBpmFlowByDeptPie.get({model:'1'});
			if (res.code == 200) {
				this.option3 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getBiBpmFlowByAccountPie()
		{
			var res = await this.$API.bpm.echarts.getBiBpmFlowByAccountPie.get({model:'1'});
			if (res.code == 200) {
				this.option4 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getUserWorkForBar()
		{
			var res = await this.$API.bpm.echarts.getUserWorkForBar.get({model:'1'});
			if (res.code == 200) {
				this.option5 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		}
	}
}
</script>

<style>
</style>
